Re-structured all core code, added character definitions