cleanup mirror logic, untested