moved setCode to private, moved srand back