Fixes issue #81, issue #59, and issue #2.  Also incorporates fixes to issue #77 and issue #78.