Clean up build_error_node function