Build in some more Rails 4.1+ hooks, move some code into Dirty module