CS fixes and a bit of refactoring to improve readability
Merge pull request #360 from vilartoni/master

CS fixes and a bit of refactoring to improve readability