Algebro-geometric sectors of solutions of the KP hierarchy are described in terms of τ-functions and vertex operators. Some useful identities involving theta functions and prime forms on Riemann surfaces are provided which are applied to obtain explicit solutions in the bilinear formalism. By using a dressing method for τ-functions the soliton dynamics against the background of quasiperiodic solutions is characterized. Furthermore, a formula for the soliton shifts in terms of prime forms on Riemann surfaces is obtained.