Added flush and register_flush functions.