Refactor lastUrlPart into seperate method
Fix memory/routine leak