removed unneeded code and general tidyup