When I test run my script, the engine simple stop responding. At a certain point, it has also displayed a "Too many shift_map() - functions" message......
It seems as if there is an endless loop or an endless recursion in your code. Perhaps a missing wait()?