cleanup code
reformat source code
correct prototypes
correct bitwise AND to bool conversion