Looks like everything is working now, just need to tidy up the code a bit.