Refactored and added some documentation.