restructured code, added support for template inheritence and blocks, extracting DB specific code into drivers (unfinished and not working)