Fixed bugs in binary handling.