Fixing issue when the application is not deployed as ROOT + other changes.