Thanks Matias A. Fonzo <selk at dragora.org> for the original patch. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>