Lots of bugfixes.

Signed-off-by: Paul Buonopane <paul+git@earth2me.com>