Move initialize and finalize into constructors and destructors.