Replace hacky hide/show handling with more straight-forward implementation.