Added an onClear method to allow lifecycle observation