Initial commit, extracted from balupton/bal-util#6501d51bc0244fce3781fc0150136f7493099237