Fixing some type specs and old API usage

run dialyzer to check that only few errors are left