Refactoring: extract monkey patches to a separate module