more preparation for layout modules

- split restacking into layout.c
- split layouts array into layout.c
hide layout specifics in layout.c
integrate tag fields