Fix for issues #9 #6 #5 #2