fixed direct memory lookup, workaround for strange bug when requested output is scalar; it will ignore first element which works but is not totally correct