Code style cleanup
minor code cleanup
Fixed a bug where state updates are not fully processed