Code review
Merge part of pull request #387 from vicb/review2

Code review