Rewrite of Initial Code

Rewrote some initial code.