Add initial log loading. Refactor js code, and make it load only where needed