add much better logging and debug messages