Code cleanup. Comments added