oh my god, tidied up a real mess, databse relationships fully working now