API Updates

This was a fairly complex merge so I apologise if I have affected any of your changes however I did run them and all appeared to be ok.

This is a fairly fundemental change to the API and code that uses it.