Fix invalid free
better macros