Technical debt

Pay back some technical debts:
* use URI instead of strings to connect to backends [done]
* use pipes-safe instead of MonadSafeIO hack
* monad haystack/needle uses overlapping instances, this is not too bad but type families might make this better?