Numerous bug-fixes & enchancements

Fixes #278.
Fixes #279.
Fixes #261.
Fixes #262
Fixes #260..