Fixed some bugs related to state retainment