Added variable sampling
General Clean up.  Added BufferUtils.hs for utility functions, now much easier to read