Add more type specs guided by Dialyzer.

Basically I added further type specs using erlc flag +warn_missing_spec then improved those specs based on the Dialyzer flag -Wunderspecs.