Refactored for organization. Adding class comments and function doc strings