Fixed #71 properly and the bugs I introduced with the last change. Fixed #68 as well.