add enable debug
better handling of error messages
clarify debug messages