Cloned input arrays to prevent modification of passed-in values, found by @Peter-Donner.  Fixes #18