Bunch of cleanup and normalization and refactoring