Cleaning up code.

Moved code around and cleaned up files