added some #if debug where needed, added callbacks on console opening