Ticket #1629 Another round of fixes related to state clearing