Deprecated original source, started rewriting for proper recursion and simplicity.