Optimize and fix bugs.