Move class inspection code to utils
Change error formatting to not use **locals()