Move entity limit to middleware.
Refactor decoders a bit