Incorporated fixes from #21