Fixed a few major bugs