Add ID_ flags in appropriate places, some tidying
Remove IDENT_EMPTY plus other small fixes