Changes made by Andrey Popov (fourpixels@gmail.com).