Code cleanup and updated comments