Replaced raw stat computations with stat computation functions where applicable.