improved path detection; can pass array of functions as plugins; minor changes