Added more exceptions
Large scale restructure and refactoring