Moves keyword mapping to the model

Keyword mapping was in the controller, this moves it to the model.