Illegal dialog modified.
Lots of cleanup about how repositories work internally; preparation for unit tests. (test file is WIP)