Cleanup to use gumbo functions when possible.

Based on blog comment suggestion by "Craig".