Fix for boundary spinning

This also contains code that will make it easier to generalize boundaries.