Removed some deprecated calls and unnecessary casts