Added Japanese and Spanish functions and refactored code.