Move error handling together
Centralized error handling
Move error handling to its own file
Remove test code