Clarified function names, added bit flipping code.