Added documentation and optimized util