need. fix minor probs, tighten code