Lots of reorganization and better templating