repairing these damn lockups. (some infinite loops, visible if debugmode = true;)