Fixed alter after free problems