Bit optimization and refactoring