Fixed most of the reported issues, aside from the metadata part