A function library used by SmartPill and SmartCloud