improved error handling
cleanup
cleanup/refactoring