fixes #9 - prefix all variables
add debug flag

using [-d|--debug] will cause wd to exit with an exit code, which is
needed when testing
minor clean up