Bug Fixes

Various bug fixes.