proper locking for OutputStream
some minor improvements
first version of talk at CUFP 2014