Rewrote logic package.