Imported from https://github.com/AlphaHounds/UBS