Rewrite to use generic API