Fix redirect loop if DB inconsistent