Add getModeAt method

Use it to prevent some unneeded state computation.