Fix selector parsing and computed value of 'display'

… and do some minor refactoring.