Bug fixes

A few bug fixes.