Cleaned core code