added a font class
made some changes to optimize state loading.