Refactoring for database and error class

More appropriate database escaping and structure. 
Converted Error class to static (cleans the code structure).
Updated the MVC files to reflect the changes.