moving constants to globals and cleaning debug code