Refactoring

* Manage output through logger
* Move form/category/post creation into seperate functions
* Move form json into a view
Add profiler calls
Add validation and missing docblocks
Tidy up and rearrange options handling code
Add import from SQL - very rough