Fixed random tree generation. Also changed  main.