Most of wai-extra rewritten