more refactoring of modem functions.