Some refactoring and library upgrade.