Separating code, adding search, adding url encoding and decoding

This was originally in several commits, a rebasing issue caused me to
lose them.