Added documentation/info and refactored functions