Improves error handling and resolves #15