added diagram and minor cleanup