Fixed some bugs, introduced others.