Fix #118 and #112