Fix url encoding related bugs