Full code review

See my comment below.