Fixed a method call on NilClass error
Locked credentials and uploaded files when it is being used

Deleted the credentials or uploaded files when it is being used
by a deployed topology may cause problems. This commit secures
this situation.