merging back fixes from leanpub