Lots of changes to support express 3, template improvements and other refactoring.