fixed reg-related bugs