[#642] Simplify check for debug mode, only create _foo once