Improve performance with big files.

I have modified the implementation of message
state. The work is done on the set method now.
In addition number_of_* properties do not call
rebuild every time.