Add bug fix for agreement file validation and some more code clean up.