Allow all possible bit-depths, not just multiples of three.
Refactor main.c.