More work on GPU code - seem to have stopped large array segfaults.