Fixed CMakeLists and template issues