Added stat function and fixed some parsing issues