debug: Simplify code

Use g_parse_debug_string() instead of a handwritten variant, and use debug
flags instead of extra env variables.