fixing some type specifications

Running dialyzer on the code failed due to some wrong type specifications. I fixed those issues as well also some others. Dialyzer still outputs errors, but fixing those will require changes to the code as well.