Made the path handling even clearer, and commented more.