Cplusplusify the code

 - style;
 - fixes;