Removed duplicated code from datastructures