Refactor components to make NLP independent of controller and query engine