Added some comments and mostly finished search