Fixed some bugs with cleaning up URLs