mostly working, still need to handle buffer-in-file and test multiple buffers