Bringing code back to working standard, as I can't remember what I was doing 9 months ago on this.