minor optimizations and block compacting