Import of the code released by Microsoft Research