bug fix and cosmetic changes.
bug fix.