Fixed some infinit loops