pulled out layout and theme generator code into standalone lib