improved handling of bottom

not ready for review yet