Refactoring: move mirror functions to external source