Rewrote some parts.