cleaning up code

refactored the layout functions file into a class, added an inherited class to output the header and footer on pages