Fix #132 and #142