Reorganize lib/
Use Railtie instead of having to add middleware manually.