Fix stream close and add Gson to rest client manager