Code rearrange; make paths more flexible