Multimatch logic and general cleanup and memory clearing.