Ported changes from my repo