MySQL support
Most of this branch is @maxking 's work from !162 (closed) which it supersedes.
This branch resolves conflicts created when the trunk has evolved, most specifically by landing the templates branch. This also cleans up a few things here and there, and ports the templates/cache tables to MySQL.