some debugging and cleanup