Fixed various issues from the PR review