Move calculation helper functions into lib so that Collection transforms don't fail on server.