changed printf to fprintf
added debug flag for enabling/disabling 2k-check debug outputs (DEBUG_2KCHECK)