Fix minor memory issues