code tidied up

I think its a good time to pull from my repo, I've tidied the code up a bit and it should be easier to work with. The code in my repo contains the changes from Josh's build branch, which I see there is already a separate pull request for.

The 'interacts with complex' case is to some extent working.