Latest merge from Enze

Includes bitwise optimizations.