Fix for too many open files and added support for multiple buckets
fixed NPE