Use ByteString instead of Text, refactor for re-use