Code cleanup and notes