Refactoring round 2. Sucked out some reusable html templates. Several enhancements. Few bug fixes