added statistics, cleanup