Copy source code from DotAHero and do some adjustments