heavy modding

these edits are many months old and I haven't touched this
code in a long time.