Fixes for #26, #40.