Big commit, Add metadata parsing. Layout changes to tree and misc fixes