More bug fixed introduced by code cleanup