Many changes to get rep.html mode working properly.