Code cleanup and whitespace fixes