split core into flexible modules, minor bug fixes