Implement set_layout()

Attempt to address Issue #515. Not sure if I'm entirely happy with this.