inject masks fixes and general bounds improvements from PR #220