Implement #180, feel free to review.