Added #ifdef statements to simplify code and updated examples