Fix bugs and screw 5.0 compat