Improve consistency and how state is maintain during analysis + bugs fix