Some preloader refactoring

I'm refactoring our preloader changes to get the code to be more similar to the Rails preloader.  This should help us to port our preloader changes to 4.2 and eventually upstream.