Make sure memory is properly allocated in case of arrays