Add new functions and fix some issues.