Issue #232

Code improvements
Several code updates to fix issues
Merge pull request #261 from FWAJL/dev

dev to master