Pull out existing re-layouting code