Code Cleanup

Deletion of old/unused code and refactoring to ease readability.