Debugging and error handling to help with #23