Small refactoring and code cleaning
Merge pull request #316 from kyuri/upstream

Small refactoring and code cleaning