Polish code to match latest changes in master branch