Back/forward ported latest updates from gharlan's official repo