Fix two bugs in f0610e60c3b220

Issue #649