give a more detailed mount error
move handling of inputs events to a function
move handling of output events to functions
factor out another repeated error checking pattern