Moved (most of the) logic out from Settings.php

Signed-off-by: emanuele <emanuele45@gmail.com>
A couple of dir-related variables not unset

Signed-off-by: emanuele <emanuele45@gmail.com>
Merge pull request #332 from emanuele45/dir_checks

Dir checks