Parameter assignment refactor

Fixed some code smells that were picked up by Sonar. The problem was that parameters were being re-assigned and then returned (instead of being assigned to local variables and returned).