refactor. added knowledge base and priority queue.