Improve shared files resolution. Fixes #162,#167