Small fixes for important bugs