Import fixes from master branch; Misc changes