Initial code audit for the Safecast API, some cherry picking from Robin