Code improvements and final touch-ups