Bug fix - detect trailing slash and remove