fix crashes (issue #56)