Code cleanup and PseudoCode added