Minor changes
Some JS refactoring to reduce ajax calls