Some critical bug fixes and DataDirectory management