fix trailing spaces and refactoring in surface_wave