add support for listing and renaming defects

this refactors a lot of the code so that it can scale less painfully, if
necessary