Debugging python model

todo: change all for i in range... into while loops due to different loop dehaviours between C++ and python.