Adds a better system for handling errors, closes #18