Implemented JS rules and and refactored js to keep it happy.