Refactor and extend registry support.