Fix NullPointerException, and pending polls not being cleared