WIP: panel support4

Supercedes PR #321.  Rebased against master, various fixes.