Added support for custom directories

It has been tested and should be okay. Feedback is more than welcome.