Ported to scala 2.10.