remove all segfaults

resulting plot is smooth, and there are no segfaults for arbitrary
dimensions of the input array.