misc debugging and cleanup