Fixes for #180, #178, #156, #155, #83