Added script to generate output directory
Added buffer locking functions