reorganizing code, making caching base directory cross-platform, small changes based on code-review