Removed an unused variable and added an OPTIMIZE comment for a future improvement.
Minor optimizations (by using more-efficient functions available in ExtCore).
Cleanup variable names in a few places.