Consolidated some changes and fixed some bugs.