Refactor and cleanup entitymanager / nodes