Added a timeout after 5000 steps
Made the simulation mode end immediately after the new episodes starts.