Replace boolean array to Bitset.
Use StringBuilder instead of StringBuffer.