code cleanup

I cleaned the code up and added a couple comments. I think it's ready!!