Updated config to be generic. tidied up code