Cleanup

Removed unused imports and moved stuff into methods.