refactor Rest/AES, tidy up....