Fixes issue #77: Bug in the layout mechanism

I and Anders have a proposal for fixing the issue with the layout mechanism.