Some refactoring, REST client updates