I think the code could do with a reformat and cleanup first.