Simplify code used to register API commands and Queries