Added court object and moved a lot fo code around