[PATCH] bfs: fix endianness, signedness; add trivial bugfix