Fix path generator and clean up code