cleanup
simplify library, more logging and error handling