I believe I fixed the pillbug.

Made some code enhancements on the way.