Refactor result reporting, move the rest of ORM code from process_bug.cgi to actual ORM class