Added flow diagram and minor fixes