Massive restructuring and clean up of codebase.