Refactored code into separate module. Added exceptions.py file.