Fixed merge issues and state issues