Added additional null checks for container and container context