Improved the BitStack class.

- Added a couple of methods for completeness.
- Added asserts for stack overflow etc. for debugging
- Added documentation
- Mask values properly for multi-bit push and pop.