Extracted exceptions and namespaced some classes
Fixed typo and refactored