Added sequence diagram and fixed a couple of bugs