Added lots of logic and tidied up some of OJS.py. Probably needs more tidying but working for now.