Improve and fix bugs in the `diagram::file/1-2` predicates