Added some casts to eliminate inexact type warnings.