Refactored and added some examples