clear buffer before close, fix a couple small bugs that prevent proper recording