Refactor keyword.evaluate to be cleaner.

@xl76: Please review after you're done testing - we'll merge afterwards.