Cropped some Egorov's code.