refactoring, cleanup and html demo