Manually merged fixes from master branch