First round of cleanup on code written years ago