Add url utility

Cleaned up some code and moved URL util functions to their own utility.