More code clean up and example code