Updated main.cpp

Added more comments about buffer logic.
Cleaned up variables names as well.