Fix registry optimization
Add registry clear