code cleanup and debug messages update