Reducing memory leaks while using Py C Api.