Fix #184, #190, #194, #208 and #211
Merge branch 'upstream-master'