Cleaning up the sample and adding documentation