erlang refactor: Add type information to the data structures.

These types can serve as a good documentation and make dialyzer's job easier.
We still cannot remove the nowarn_deprecated_type because of dialyzer's problem
with worker_throttle.