Fix #107 and #108

See #107 and #108 for details.