Converted program to OO style.