cleaning up the code

because it is necessary if I am ever to finish this.