Added minor comments and cleaned code