refactored stats tables

still have bug returning array of arrays!?!?
create db connection factory