Probably the biggest offense against DRYness I've ever seen, but oh well, I think the losing state on refresh issue is solved