Added some null-checks so that service invocation works.