fixed issues pointed out by @turicas