Renamed uid to id and tidied up.