replace raw pointer to UI with reference
use a vector instead of a raw array
make comments in main consistent
improve const correctness