Re-orgs code to have factory constructor at start of file