OOPified and added analysis.