code polish
fix coding style
constify pointers
use const ref when possible