Cleanup code & optimize imports

Cleans up code throughout the project and optimizes imports.