Moved all logic to a single middleware piece inserted after remote ip. All info is now extracted from actiondispatch request.