Rewritten path handling in core, added more debug outputs.