Fix #550
Fix #551
Fix #513