A lot of changes. This is messy but almost fully functional. I don't
intend to finish it since I don't think it will ever be used.