Optimization and minor changes
Merge pull request #11 from erderse/Branch-2

Optimization and minor changes