More bug fix and refactoring

No match.