added in new constrain code to fix burry images. Fixes #92

Adding this from Chance's repo.