Issue 38, 39 and 31 fixed