Fixed a warning and updated to newer APIs