Added inline documentation
Code clean up