Added some error handling, entire existing codebase now working