Did some cleanup and code-style refactoring