refactored and document bit manipulation functions, improved mainpage docs