Merge the code from #37 (original from #33)