Added clean view and code clean up

Added clean view function to remove events and clean state