wrote more comments; cleaned up unused code