Reformat merge, cleanup, fix wrong free