Alpha k rewrite machine (not ready for review)

Testing...