Removing some unused variables.
Refactoring and improving code.
Remove unused variables in the spectrum file.
Some code style changes and improvements.