Attempted fixes for #124, #125, #126, #127.