Added configuration options and fixed bug

- Added databse directory and file creation check
- Some refactoring in BST index
- Fixed bug in BST index for free entries