Copied from legacy elib