Fixed some major bugs