Restructure the func register code.