Loop handler fixes