Complete re-write using model/view architecture