Minor refactoring and optimization.

doh! of course that's better. :)