Refactored zorder function and a few visual tweaks.