Added more documentation

Added more documentation & small optimizations