Changed error handling

Will now send the error in the model.
Refactored code in API to be more usable

D:
Restructuring API
Restructure API
Tested

Merge with master