Cleaned up cast method.