More Improvements and Various Fixes

Fixed issues reported from previous pull request, improved code formatting, fixed some repetitive variable naming, did some more cleanup on HTML.