Don't have time to comment in details but wanted to warn about one thing : don't over-engineer. There is only limited value in a smart utility if its usage pattern can't be immediately recognized by a new developer.