Add bounds check and regex cleanup magics