Fixing issue #80. - Some refactoring and better logic.
Merge branch 'development'