Compatability fixes

Added functionality for older versions of php. Fixed issues with path to working directory.