Major restructure

The restructure also closes issue #5, which is long overdue, sorry!