fix compression loop (with begin/end) + some extra logging