Updated code to latest SDK changes