Code review refactoring

I am planning on putting out the 4.0.0-RC tonight or first thing tomorrow... let me know if this PR is ok with you.