Merge pull request #327 from shaitan/master

Applied changes from lts branch.