Cleanup code & optimize imports

Cleans up code throughout the project and optimizes imports.

Fixes #190, but does not have backwards compatibility with earlier versions of EE.