Generalize, some cleanup