Rewrite to avoid exec calls and use DB for configuration