[#4] Fixed issues discribed in comments under commit 30fc18cc22dcb321f8aa0609a00e54bd8253287b