Improved code for nav positioning and a few other elements