Optimizations/Code cleanup

Improves speed, memory usage and readability. Main point is to avoid instantiating new Paths/String everytime, instead passing Path references.