Minor bug fixes.

Pretty much complete.