Add chargen server and restructure code