added chaching of Aid to UID and moved some things around in state