Incorporated fixes from #18