Refactoring and basic implementation of RMI.