Fix important bugs