Cleanup js, introduce logging flag