Fix issues mentioned in the PR review (still in progress)