Mostly Figured Out

Most of the main logic has been figured out. Needs to be cleaned up, fix
some smaller existing problems, and commented so I don't forget why I
did things the way I did.