Refactor output of package files, split out basics into lib file