Bug fixes

Fixe a few bugs.