added pwdir functionality and fixed some stuff