Reorganize controllers, fix template compilation