Catch bad_numeric_cast, rethrow better

Also, use long, not int32_t, for rxp moving average. This seems slightly
clearer to me.

Per @abellgithub's comments on 51b11498cdc4f11c765cf723625100d826aa4da6.