Add last_action in notify state
Fix bugs, code cleanup