Fixed Issue #1

Moved functions around to use a max stack depth of 7.