Here and in the function below, we should probably move this arrays to the outer scope.  Even though they have literal elements, I'm not sure if they'll get allocated on every call.