implementing sanity checks and refactoring
main2.R finished, doing plots