Small JS formatting and efficiency updates

Less code ftw