Moved initialize and finalize to Memory from Gadget to new classes.