Partial fixes for #654, #653 and #589