Add constructor functions to commands.

Also avoid creating the regexp patterns every time.