Fixed some bugs and began using StringBuilder instead of String.