Apply @polachok patch to fix #77

Solution given by @polachok seems to be satisfied all issue responders. Why we still don't have this in master branch?