Various bugfixes.

Whee.