Various casts fixed thank to Edgar