Fixes to bugs