chart added, tidied up some code

bug fixes