Move left-over Memory finalize logic
Split out socket logic