refactored counter_stats.
reorganized build scripts with makefile.