split main.hs into new files; add license notice