tidied up some bugs