Fix some major bugs