Enabled ajax auth & Minor improvements and refactorings.