compile fix and correctness fix #820