use precomputed flags (ground,fo) to improve some functions