Fixed memory leaks in apply_basis_axioms