A few major changes, including cleanup and optimization.