Fix for #82 and other fixes