some bug fixes, already recorded in gh-pages branch