Fix #520
Fix #517