Undebug, minor refactoring