Refactor and fix doctrine bundle BC break