Fixed unexpected output of function return (data frame). Code cleanup.