invalid entities bugs + code review