Split plugin_handler.c for readability, several minor changes.