Lots of changes, starting to extract JS