Fixed few casting errors