Bug fix and polish