Code cleanup and additional comments