Refactor to pass around a layerParams_t object.