Refactor to match the proposed changes
Clear buffer if handler is removed