v0.5.20 - convert entity indexes to use guaranteed references

also, minor code cleanup