Added a MAX_VALUE variable,fix some minor bugs