Bug Fix, Optimization

Various Bug Fix
Moved AJAX first call to opened file