Porting previous buggy code.