Refactored sidebar code and pushed it into the theme