Move core functionality into separate directory