MOB-116: Refactoring problematic loops