Refactor clear buffer system (issue #128)