Added documentation & removed unused code