Factor some repeated lines of code into a helper function, per Bill's feedback. Also added support for the places property in the constraints object