Added a finalize handler