Reorganize and extend command API