Implemented proper maximal catching + optimizations