Some code cleanup with major improvements for printf-like format API.