Refactor and fixed some warnings that Sonar showed us