Fixed the levelstate generator functions