Fixed bugs duplicate on sonar and deleted some unused variables.