Remove battery from rack.
Remove two philips screws on dock cover.
Remove the cover from the dock by depressing the latches on the side.
Hold the 2 philips bolts (C in picture below) from turning on the inside of the dock while you remove the nut on the underside of the rack. Hardware B has nuts (black-also labeled B) on the underside of the rack too but is a captured bolt head on the top.
On the underside of the rack you have to remove all the nuts indicated in the picture below. All of them have a corresponding philips head accessible from the top side of the rack except for the black nuts (B) near the front; those have a square head that is kept from rotating by the channel it sits in (see B image above).
Bolts/nuts labeled A (in picture above) are for the battery tray. The image below shows the head of those bolts when viewed from the top.
With all the hardware removed, the dock is free to slide out of the rack towards the front of the bicycle. The wires will still keep it tethered to the rest of the bicycle. The battery tray should come off in multiple segments, leaving a bare rack.
Once the dock and the battery tray have been removed from the rear rack, you can remove the rack from the frame. There are two upper rack struts and two lower rack struts that need to be removed. They are circled in the image below.
Bolt the replacement rack onto the frame by mounting all 4 struts. Adjusting the angle can be done after the struts/rack are fastened to the frame.
Install the battery dock first, fastening but not completely tightening the hardware. The battery tray is installed next. Refer to the pictures above for orientation and placement of hardware. Once every bolt/nut has been installed, go through and tighten all hardware appropriately.