Refactored core (Some problems were stayed)