Common functions and URL processing