Fix for issues #24 and #43

#24
#43