Added error html pages
Removed some dead code
Added malicious input handling and improved logging robustness and uniformity