Fixes from Master

Same fixes from Master commit 32652ca907875963146b2350893f75a176538070