Added code to copy grid maps to device memory if necessary