Refactoring and several changes to Android client.