fix several small bugs

@lennartcl