Fixed some bugs introduced with latest changes.