Refactor code to separate Model from Controller

* Note handling functions moved to a new class in a separate file.
* secure_remove tweaked to remove all existing files in one call.