removed duplicated mode constants
moved constants into top-level module
refactored out duplication into base class
refactored out stream logic into base class