some fixes for crashing loop