Better layer selection with changing layer heights

Integrating Changes provided by Dirkels
This resolve issues with finding the right layer to swap at when
different heights are selected.