Greatly refactor and enhance the mirror implementation