Clean up and begin refactoring

Used eclipse's Web Tools Platform to format this in a more google-like
style. Also began refactoring. Added TODOs for what's needed next.