Fix properly types casts.
Added dependencies check.
missing file in previous commit