Fixed probably unneeded duplications in parts of code

Hello,
I've removed some duplicated pieces of code I found to be duplicated.
Please, look at it and consider pulling in, if you agree ;)

Also some trailing spaces at end of lines were auto-truncated.