Moving keyword handling to a new class

For issue #888