some micro-optimizations, and one bug fix in bit planar kernel