Various additions and bug fixes.

-- R. Ferdman, 21 October 2013