Fix bug in singleton generation