Added more documentation, fixed bug in dot product function