Refactor to segregate Mosh-specific from generic wrapper functionality.