fix url decode and several bugs