Remove whitespace
Misc refactorings, fixes