Fixed most of the bugs.