adding AbstractKnowledgeEncoding

plus some refactoring