Added xhr_wait_states and bug fixes