Refactoring and improving the ECS and its surrounding code