fixes for issues #803, 676, 637