Proper memory freeing behavior, courtesy of Travis