Fixed xml refresh bug and refactored/commented much content