Refactored phase handlers on client and server side.