Fixed Dialyzer warnings, still need some refactoring.

Have fixed some dialyze warnings.

Still some code needs to be checked again.

But now we don't have more warnings from dialyze.