Fixed a series of issues, see gh-pages branch for details.