Some fixes for #111 and #155