Fix several small issues

@lennartcl 

also fixes #1841, #2136, #2133