backend work and several fixes and improvements