array index bug fixed, minor cosmetic changes.