Improved performance and cleaned up some var names.