Update model building to Alexey's version.