A lot of refactorings. Deprecated renderXXX() methods and changed the render() interface to accept many options, ready for future additions. Added basic test suite, but still needs a bit of work.