DDF-440: Updated to check for null serviceref.

Also synchornized start and stop to prevent possible race condition. Starting and stopping applications are generally not an operation that is done very often so synchronizing the entire method should not impact performance.