Fix some bugs, add conditionalState