added finalization stuff