Redefined smart pointer classes in safer way

Changed the smart pointer type definitions from the macros to the wrapper classes.