A few code improvements based on the code review document