Make the extension registration nicer

and don't leak vars.

Change-Id: I1df47b07d7dd6dd5b61dece30ef8d4cfe4f30e33
Merge "Make the extension registration nicer"