Fixes for issues 662, 664, 343