big refactoring - still needs docs. bumping to v0.4.0