Survived first round of debugging. Semifunctional.