Various bug fixes.

-- R. Ferdman, 7 November 2014