cmake project and small code improvements