Removed all trailing whitespace and adapted refactorings.

This commit removes all trailing whitespace from the code and
also adapts the refactorings so that they don't create unnecessary
whitespace (e.g. indented empty lines to separate methods).