Refactoring some code in the neo4j backend.