Code cleanup based on comments