Fixed some issues mentioned by Sadegh
Fixes #7