many bug fixes
Merge pull request #167 from clovis/master

many bug fixes