Fix multiple issues

Fix for issues #5  , #8  , #9