Fix Issue #8 and #9

Though not quite sure whether this is the best way fixing - please verify and merge if OK. Thank you.