More progress - probably needs to be rewritten, putting on hold for now