Add command callback table support

This PR targets #365. It is WIP but I'm ready for review here.