Cleanup grok code for Issue 927

Fixes #927. The unit tests work for me, so I thought i'd re-pull and see if this time it passes the travis build.