Proposed solution. It will not fix the existing case but the future upgrades: https://gist.github.com/darix/b5c5868b8730ae67c62a4f1c6de5125b