Adjusting for server side API changes.

Also refactored a little.