Fix issues mentioned in comments