Made the path handling a little more clear, and commented.