Add support for basepath property, fixes #4

Also some other mixed fixes, template cleanup etc.