MVC-ish refactor

- refactored the code to make it more MVC
- fixed a bug that prevented folder titles from being edited