Corrected casted types

This is a cherry pick of the rcXXXX branch

Why the hell are bugfixed only on the rcXXXX branch an not on master.....