massive refactor with registry