Copy implementation from yesod-fay