cleaned up file/buffer case handling with some macro magic