Fixed a bug and a performance issue.