cleanup and debug