Mistake 1: deciding from one word alone
بَعْدَ may refer to time in one sentence and another relation in another. Read the whole phrase.
Mistake 2: leaving tanwin on the mudaf
Use فَوْقَ الْبَيْتِ, not فَوْقًا الْبَيْتِ, when the house completes the relation.
Mistake 3: ignoring the second noun
In أَمَامَ الْمُعَلِّمِ, the teacher is not the adverb. أَمَامَ is the adverb; الْمُعَلِّمِ is mudaf ilayh.