fix #99 and #103 tnx to @stefan-niedermann