Fix issues #471, #482, #499 and #550