Added check that variable is Object before cloning on it. Also added handles in case getImage returns null