Database optimizing & input charset fix