Fixed some bugs caused by the recent API changes.