Merging v2 branch (complete overhaul)