fixed some ruby warnings
Change if not to unless
Land #3348, some Ruby warning fixes