Fixed removeAllStatesExcept and added comments.