Some bug fixes.

Just some bugs fixed here and there and here...