Trying to fix part of the pointed issues from the previous pull request