Initial conversion of logic. Fix bug in resize().