change open files to python best practice recommendations
handle OS error 17 in a cleaner way
support CCM, CAF and aii
fixup leftovers from rebase