Fix #174 and #171