Backport codes from Scala 2.8 branch to Scala 2.7 branch