Added calls to free()