Added better work dir detection and fixed checkpath indentation