Neated up code and fixed bug in default/user config