restructured some the base code; added layer builder method