Unset some vars to free memory and some more small corrections