Restructuring and example code updated