Fix #401
Fix #389
Fix #388