Refactorized core code