Re-organised code a little to put directory config at top of file