Replace deprecated method calls and fixed warnings.