Kirill's miscellaneous functions