A bit of refactoring to update client and commonize some functionality.