Copied from scala-dist