v2.5.0. Extracted from balupton/bal-util