Various refactoring across the entire project. Added ability to parse errors and return messages to user