Refactor controllers, moves some logic to models, fixes theme switching