Some refactoring. HDFS support updated.