Fixed performance issue.

Also fixed bug and cleaned up code in CR3.js