Fix #588
Fix #575
Fix #636