Create safeRelease macro and resolve leaks