More jQuery hacking, lots of tidyup needed.