Reverted previous changes and instead check if container is within document. #41