fix some errors, bitwise problems, testing problems