Fixed some performance issues.