refactoring started, now to fix errors
fair bit of bug fixes. almost there
latest melon. Fixes #2. Finishes refactor
fixed merge