fixed #604. Thanks, @Gubolin!
fixed #608, #610