Interplay of spin waves and vortices in the two-dimensional XY model at small vortex-core energy