Fix grammar and some code logic (#2211)