Some re-org and a bug fix.