Merge "Fix loop limits." into klp-dev