Fixes  a few bugs.