Replace custom exception by KeyError
Merge exception cleanup