Fix #518
Fix #519
Fix #518
Fix #519