Trackwork and wiring, the two most important parts of the layout for smooth/reliable operation.
I've seen a few layouts with large gaps between track sections and undulating rails.
I've never had a derailment that wasn't operator error, i.e. a turnout thrown incorrectly etc.
One thing I did when building my layout was sighting down the top of the rails at eye level.
I then removed and dips and rises by either shimming or snugging down track screws.
This is especially important near turnouts.