fix 2 critical bugs